👀 Reading hidden code
missing
👀 Reading hidden code
ClickCounterWithReset (generic function with 3 methods)
👀 Reading hidden code
ClickCounterWithReset(text="Click", reset_text="Reset") = HTML("""
<div>
</div>
<script id="blabla">
// Select elements relative to `currentScript`
const div = currentScript.previousElementSibling
const button = div.querySelector("button")
const reset = div.querySelector("#reset")
// we wrapped the button in a `div` to hide its default behaviour from Pluto
let count = 0
button.addEventListener("click", (e) => {
count += 1
div.value = count
div.dispatchEvent(new CustomEvent("input"))
e.stopPropagation()
})
reset.addEventListener("click", (e) => {
count = 0
div.value = count
div.dispatchEvent(new CustomEvent("input"))
e.stopPropagation()
e.preventDefault()
})
// Set the initial value
div.value = count
</script>
""")